{layout name="/base" /}

<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css" />
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=a7e2fc1a96a83283106bf583328aa248&plugin=AMap.Autocomplete"></script>
<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
<!--载入百度编辑器所需js文件-->
<script type="text/javascript" charset="utf-8" src="/UEditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/UEditor/ueditor.all.min.js">
</script>
<script type="text/javascript" charset="utf-8" src="/UEditor/lang/zh-cn/zh-cn.js"></script>
<!--图片上传-->
<link rel="stylesheet" type="text/css" href="/diyUpload/css/diyUpload.css">
	<div class="row">
		<div class="col-lg-12">
			<h1>营地管理 <small>营地信息编辑</small></h1>
			<ol class="breadcrumb">
				<li><a href="/index"><i class="fa fa-dashboard"></i> 管理首页</a></li>
				<li><a href="/camps"><i class="fa fa-dashboard"></i> 营地列表信息</a></li>
				<li class="active"><i class="fa fa-table"></i> 营地信息编辑</li>
			</ol>
			<div class="alert alert-success alert-dismissable">
				<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button> 请准确编辑营地信息
			</div>
		</div>
	</div>
	<!-- /.row -->
	<div class="row">
		<!-- 选项卡start -->
		<div class="bs-example">
			<!-- 选项卡标题start -->
			<ul class="nav nav-tabs" style="margin-bottom:15px;">
				<li class="active">
					<a href="#one" data-toggle="tab">营地基本信息</a>
				</li>
				<li>
					<a href="#two" data-toggle="tab">营地介绍图文信息</a>
				</li>
			</ul>
			<!-- 选项卡标题end -->
			<form class="form-horizontal" role="form" id='checkCamp' action="/camps/{$list.id}" method="post" enctype="multipart/form-data">
				<input type="hidden" id='method' name="_method" value="PUT">
				<input type="hidden" name="old_rent_money_base" value="{$list.rent_money_base}">
				<!-- 选项卡内容start -->
				<div id="myTabContent" class="tab-content">
					<!-- 选项卡内容1会员类型start -->
					<div id="one" class="tab-pane fade active in">
						<!-- 基本信息start -->
						<div class="col-lg-11">
							<div class="form-group">
								<label class="control-label col-sm-2" style="color: red; font-size: 16px;">营地旅行币基数</label>
								<div class="col-sm-4">
									<input class="form-control" type="text" name="travel_money_base" value="{$list.travel_money_base}" placeholder="请填写旅行币基数" />
								</div>
								<label class="control-label col-sm-2" style="color: red; font-size: 16px;">营地单日出租基数</label>
								<div class="col-sm-4">
									<input class="form-control" type="text" name="rent_money_base" value="{$list.rent_money_base}" placeholder="营地单日出租基数" />
								</div>
							</div>
							
							<div class="form-group">
								<label class="control-label col-sm-2" style="color: red; font-size: 16px;">所在热门城市</label>
								<div class="col-sm-4">
									<select class="form-control" name="area">
				                        {foreach $city as $k => $vc}
				                            {if $list.area eq $k}
				                        		<option selected='true' value={$k}>{$vc}</option>
				                        	{else}
					                       		<option value={$k} >{$vc}</option>
					                       	{/if}
				                        {/foreach}
				                    </select>
								</div>
							</div>
							
							<!-- 营地信息start -->
							<div class="form-group">
								<label class="control-label col-sm-2">营地编号</label>
								<div class="col-sm-4">
									<input class="form-control" type="text" name="number" value="{$list.number}" placeholder="sjz85468585">
								</div>
								<label class="control-label col-sm-2" style="color: red;">营地名称</label>
								<div class="col-sm-4">
									<input class="form-control" type="text" name="name" value="{$list.name}" placeholder="请填写营地名称">
								</div>
							</div>
							<div class="form-group ">
								<label for="firstname" class="control-label col-sm-2">营地类型</label>
								<div class="col-sm-4">
									<select class="form-control" name="type">
				                      {foreach $types as $k => $type}
				                      {if $list.type==$k}
				                       <option value={$k} selected='true'>{$type}</option>
				                       {else}
				                       <option value={$k} >{$type}</option>
				                       {/if}
				                      {/foreach}
				                    </select>
								</div>
								<label for="firstname" class="control-label col-sm-2">营地星级</label>
								<div class="col-sm-4">
									<select class="form-control" name="grade">
				                      {foreach $grades as $k => $grade}
				                      {if $list.grade==$k}
				                       <option value={$k} selected='true'>{$grade}</option>
				                       {else}
				                       <option value={$k} >{$grade}</option>
				                       {/if}
				                      {/foreach}
				                    </select>
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-sm-2" style="color: red;">泊位数量</label>
								<div class="col-sm-4">
									<input class="form-control" type="text" name="count" value="{$list.count}" placeholder="请填写泊位数量">
								</div>
								<label class="control-label col-sm-2">营地描述</label>
								<div class="col-sm-4">
									<textarea class="form-control" type="text" name="profiles" placeholder="请填写营地名称"> {$list.profiles}</textarea>
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-sm-2" style="color: red;">超级管理员手机</label>
								<div class="col-sm-4">
									<input class="form-control" type="text" name="campmanager_phone" value="{$list.campmanager_phone}" placeholder="请填写手机号码" />
								</div>
								<label class="control-label col-sm-2" style="color: red;">超级管理员姓名</label>
								<div class="col-sm-4">
									<input class="form-control" type="text" name="campmanager_name" value="{$list.campmanager_name}" placeholder="请填写负责人姓名">
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-sm-2" style="color: red;">营地联系电话</label>
								<div class="col-sm-4">
									<input class="form-control" type="text" name="tel" value="{$list.tel}" placeholder="请填写其他联系电话" />
								</div>
								<label class="control-label col-sm-2" style="color: red;">邮箱</label>
								<div class="col-sm-4">
									<input class="form-control" type="text" name="email" value="{$list.email}" placeholder="请填写营地负责人邮箱" />
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-sm-2">统一社会信用代码</label>
								<div class="col-sm-4">
									<input class="form-control" type="text" name="credit_code" value="{$list.credit_code}" placeholder="请填写营业执照统一社会信用代码" />
								</div>
								<label class="control-label col-sm-2" style="color: red;">法人代表</label>
								<div class="col-sm-4">
									<input class="form-control" type="text" name="legal_person" value="{$list.legal_person}" placeholder="请填写法人" />
								</div>
							</div>
							
							<div class="form-group" id="addressD">
								<!--详细地址-->
		                    	<label class="control-label col-sm-2" style="color: red;">详细地址</label>
			                   	<div class="col-sm-4">
				                    <input class="form-control" type="text" name="address" value="{$list.address}" placeholder="请输入营地所在详细地址"/>
			                   	</div>
								<!--地址开始-->
								<label class="control-label col-sm-2">地址</label>
			                    <select name="addressCountry" class="addressCountry" data-first-title="选择国家"  data-value="{$list.country}" data-url="/camps/getcountry" style="width:100px;" ><select>
			                    <select name="addressProvince" class="addressProvince" data-first-title="选择省"  data-value="{$list.province}" data-url="/camps/getprovince" style="width:100px;"><select>
			                    <select name="addressCity" class="addressCity" data-first-title="选择城市" data-value="{$list.city}" data-url="/camps/getcity" style="width:100px;"><select>
			                </div>
							<!--地址结束-->
							<!--封面图片-->
							<div class="caravan-info-form">
								<h3 style="font-size: 14px; padding-left: 73px; font-weight: 600;">营地封面图片（请按规范上传1张）</h3><br>
								<div style="margin:5px auto;width:875px; min-height:200px;">
									<div id="caravancover">
									    <div id="fileList" class="uploader-list"></div>
									    <div id="filePicker"></div>
									</div>
									{foreach $list['cover'] as $vv}
										<img class="img-responsive" src="{$vv}">
									{/foreach}	
								</div>
							</div>
							<!--内容图片-->
							<div class="caravan-info-form">
								<h3 style="font-size: 14px; font-weight: 600;">营业执照图片（请按规范上传1张）</h3>
								<div style="margin:5px auto;width:875px; min-height:200px;">
									<div id="caravanphoto"></div>
									{foreach $list['license'] as $v}
										<img class="img-responsive" src="{$v}">
									{/foreach}
								</div>
							</div>
							<!-- webuploader图片上传 -->
							<script type="text/javascript" src="/diyUpload/js/webuploader.js"></script>
							<script type="text/javascript" src="/diyUpload/js/diyUpload.js"></script>
							<script type="text/javascript">
								$(function(){
									/*
									* 服务器地址,成功返回,失败返回参数格式依照jquery.ajax习惯;
									* 其他参数同WebUploader
									*/
									$('#caravancover').diyUpload1({
										url:'/uploadimg',
										success:function(data) {
											$('#checkCamp').append('<input type="hidden" name="cover" value="'+data.url+'" />');
										},
										error:function( err ) {
											// console.info( err );	
										},
										buttonText : '选择房车封面',
										//最大上传的文件数量, 总文件大小,单个文件大小(单位字节);
										fileNumLimit:1,
										thumb:{
											width: 800,
							    			height: 200,
										}
									});
									$('#caravanphoto').diyUpload({
										url:'/uploadimg',
										success:function( data ) {
											$('#checkCamp').append('<input type="hidden" name="license" value="'+data.url+'" />');
										},
										error:function( err ) {
											console.info( err );	
										},
										buttonText : '选择1张营业执照图片',
										chunked:true,
										// 分片大小
										chunkSize:512 * 1024,
										//最大上传的文件数量, 总文件大小,单个文件大小(单位字节);
										fileNumLimit:1,
										fileSizeLimit:500000 * 1024,
										fileSingleSizeLimit:50000 * 1024,
										accept: {},
										thumb:{
											width: 388,
							    			height: 200,
										}
									});
								}); 
							</script>
							
							<!-- 地图start -->
							<div class="form-group">
								<label for="firstname" class="control-label col-sm-2">营地地图</label>
								<div class="col-sm-10 campmap">
									<div id="container"></div>
									<div id="myPageTop">
										<table>
											<tr>
												<td>
													<label>按关键字搜索：</label>
												</td>
												<td class="column2">
													<label>左击获取经纬度：</label>
												</td>
											</tr>
											<tr>
												<td>
													<input type="text" placeholder="请输入关键字进行搜索" id="tipinput">
												</td>
												<td class="column2">
													<input type="text" readonly="true" id="lnglat">
													<input type="text" name="lng" id='lng' value='{$list.lng}' />
													<input type="text" name="lat" id='lat' value='{$list.lat}' />
												</td>
											</tr>
										</table>
									</div>
									<script type="text/javascript">
										//地图插件
										var map = new AMap.Map("container", {
											resizeEnable: true,
											center:[{$list.lng},{$list.lat}],
											zoom: 15
										});
										var marker = new AMap.Marker({
											position: [{$list.lng},{$list.lat}],
											draggable: true,
											cursor: 'move',
											raiseOnDrag: true
										});
										marker.setMap(map);
										//为地图注册click事件获取鼠标点击出的经纬度坐标
										var clickEventListener = map.on('click', function(e) {
											document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat();
											document.getElementById("lng").value = e.lnglat.getLng();
											document.getElementById("lat").value = e.lnglat.getLat();
											marker.setPosition([e.lnglat.getLng(), e.lnglat.getLat()])
										});
										var auto = new AMap.Autocomplete({
											input: "tipinput"
										});
										AMap.event.addListener(auto, "select", select); //注册监听，当选中某条记录时会触发
										function select(e) {
											if (e.poi && e.poi.location) {
												map.setZoom(15);
												map.setCenter(e.poi.location);
												document.getElementById("lnglat").value = e.poi.location.getLng() + ',' + e.poi.location.getLat();
												document.getElementById("lng").value = e.poi.location.getLng();
												document.getElementById("lat").value = e.poi.location.getLat();
												marker.setPosition([e.poi.location.getLng(), e.poi.location.getLat()])
											}
										}
									</script>
								</div>
							</div>
							<div class="form-group">
								<div class="btn-group mybtn col-sm-4 col-sm-offset-2">
									<a href="#two" data-toggle="tab" class="btn btn-primary">下一步</a>
								</div>
							</div>
							<!-- 营地信息end -->
						</div>
						<!-- 基本信息end -->
					</div>
					<!-- 选项卡内容1会员类型end -->
					<!-- 选项卡内容2级别start -->
					<div id="two" class="tab-pane fade">
						<!-- 基本信息start -->
						<div class="col-lg-12">
							<!--调用百度编辑器开始-->
							<script id="editor" type="text/plain" style="width:85%;height:500px;" name="content">{$list.content}</script>
							<script>
								UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
								UE.Editor.prototype.getActionUrl = function(action) {
									if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') {
										return '/uploadueditor';
									} else if (action == 'uploadvideo') {
										return 'http://a.b.com/video.php';
									} else {
										return this._bkGetActionUrl.call(this, action);
									}
								}
								var ue = UE.getEditor('editor', {
									toolbars: [
										[
											'fullscreen', 'source', '|', 'undo', 'redo', '|',
											'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
											'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
											'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
											'directionalityltr', 'directionalityrtl', 'indent', '|',
											'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
											'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
											'simpleupload', 'insertimage', 'emotion', 'map', 'gmap', 'insertframe', 'insertcode', 'background', '|',
											'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
											'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
											'print', 'preview', 'searchreplace', 'drafts', 'help'
										]
									]
								});
								ue.addListener('ready', function() {
									ue.focus();
								});
							</script>
							<!--调用百度编辑器结束-->
						</div>
						
						<div class="form-group">
							<div class="btn-group mybtn col-sm-4 col-sm-offset-8">
								<button class="btn btn-primary" type="submit">审核通过</button>
								<button class="btn btn-primary" id="notPass">审核未通过</button>
							</div>
						</div>
					</div>
					<!-- 基本信息end -->
				</div>
				<!-- 选项卡内容2级别end -->
		</div>
		<!-- 选项卡内容end -->
		</form>
	</div>
	<!-- row -->
<script type="text/javascript">
	//世界城市地区联动 开始
	$('#addressD').cxSelect({
	    selects: ['addressCountry','addressProvince', 'addressCity'],
	    jsonName: 'area_name',
	    jsonValue: 'area_code'  }, function(api) {
	    cxSelectApi = api;
	});
	//世界城市地区联动 结束
	$('#notPass').click(function(){
		$('#checkCamp').attr('action','/camps/notPass/{$list.id}');
		$('#checkCamp').submit();
	})
	
</script>